import { BasicColumn, FormSchema } from '/@/components/Table';
import { Tag } from "ant-design-vue";
import { h } from "vue";


// 表格定义
export const columns: BasicColumn[] = [
  {
    title: '委托单位',
    dataIndex: 'clientName',
  },
  {
    title: '摘要',
    dataIndex: 'summary',
    customRender: ({ record }) => {
      return record.work ? record.work.summary : '';
    },
  },
  {
    title: '发起人',
    dataIndex: 'operatorName',
    customRender: ({ record }) => {
      if (record.work) {
        const color = 'green';
        const text = record.work.operatorName;
        return h(Tag, { color: color }, () => text)
      }
      return '';
    },
  },
  {
    title: '发起时间',
    dataIndex: 'work.startTime',
    customRender: ({ record }) => {
      return record.work ? record.work.startTime : '';
    },
  },
  {
    title: '完成时间',
    dataIndex: 'work.stopTime',
    customRender: ({ record }) => {
      return record.work ? record.work.stopTime : '';
    },
  },
  {
    title: '流程状态',
    dataIndex: 'statusName',
    customRender: ({ record }) => {
      if (record.work) {
        const color = record.work.status == 20 ? 'red' : 'green';
        const text = record.work.statusName;
        return h(Tag, { color: color }, () => text);
      }
      return ''
    },
  }
];

/**
 * 搜索字段定义
*/
export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '关键字',
    component: 'Input',
    componentProps: {
      placeholder: '请输入名称/标识',
    },
    labelWidth: 60,
    colProps: { span: 6, lg: { span: 6, offset: 0 }, sm: { span: 10, offset: 0 }, xs: { span: 16, offset: 0 } },
  },
];





